'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _extends2 = require('babel-runtime/helpers/extends');

var _extends3 = _interopRequireDefault(_extends2);

var _objectWithoutProperties2 = require('babel-runtime/helpers/objectWithoutProperties');

var _objectWithoutProperties3 = _interopRequireDefault(_objectWithoutProperties2);

var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');

var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);

var _createClass2 = require('babel-runtime/helpers/createClass');

var _createClass3 = _interopRequireDefault(_createClass2);

var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');

var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);

var _inherits2 = require('babel-runtime/helpers/inherits');

var _inherits3 = _interopRequireDefault(_inherits2);

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _propTypes = require('prop-types');

var _propTypes2 = _interopRequireDefault(_propTypes);

var _collapse = require('antd/lib/collapse');

var _collapse2 = _interopRequireDefault(_collapse);

var _row = require('antd/lib/row');

var _row2 = _interopRequireDefault(_row);

var _col = require('antd/lib/col');

var _col2 = _interopRequireDefault(_col);

var _tag = require('antd/lib/tag');

var _tag2 = _interopRequireDefault(_tag);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }

var Panel = _collapse2['default'].Panel;

var CheckableTag = _tag2['default'].CheckableTag;

var EditorClassName = function (_Component) {
  (0, _inherits3['default'])(EditorClassName, _Component);

  function EditorClassName() {
    var _ref;

    var _temp, _this, _ret;

    (0, _classCallCheck3['default'])(this, EditorClassName);

    for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
      args[_key] = arguments[_key];
    }

    return _ret = (_temp = (_this = (0, _possibleConstructorReturn3['default'])(this, (_ref = EditorClassName.__proto__ || Object.getPrototypeOf(EditorClassName)).call.apply(_ref, [this].concat(args))), _this), _this.state = {}, _this.onChange = function (value) {
      _this.props.onChange(value);
    }, _temp), (0, _possibleConstructorReturn3['default'])(_this, _ret);
  }

  (0, _createClass3['default'])(EditorClassName, [{
    key: 'render',
    value: function render() {
      var _this2 = this;

      var props = (0, _objectWithoutProperties3['default'])(this.props, []);
      var value = props.value,
          classNameArray = props.classNameArray,
          editClassName = props.editClassName,
          locale = props.locale;

      ['value', 'onChange'].map(function (key) {
        return delete props[key];
      });
      return _react2['default'].createElement(
        Panel,
        (0, _extends3['default'])({}, props, { header: props.header || locale.header }),
        _react2['default'].createElement(
          _row2['default'],
          { gutter: 8 },
          _react2['default'].createElement(
            _col2['default'],
            null,
            locale.exclusive
          )
        ),
        _react2['default'].createElement(
          _row2['default'],
          { gutter: 8 },
          _react2['default'].createElement(
            _col2['default'],
            null,
            _react2['default'].createElement(
              CheckableTag,
              {
                key: editClassName,
                onChange: function onChange() {
                  _this2.onChange(editClassName);
                },
                checked: value === editClassName
              },
              editClassName
            )
          )
        ),
        !!classNameArray.length && [_react2['default'].createElement(
          _row2['default'],
          { gutter: 8, key: 'name' },
          _react2['default'].createElement(
            _col2['default'],
            { span: 24 },
            locale.common
          )
        ), _react2['default'].createElement(
          _row2['default'],
          { gutter: 8, key: 'select' },
          _react2['default'].createElement(
            _col2['default'],
            { span: 18 },
            classNameArray.map(function (key) {
              return _react2['default'].createElement(
                CheckableTag,
                {
                  key: key,
                  onChange: function onChange() {
                    _this2.onChange(key);
                  },
                  checked: value === key
                },
                key
              );
            })
          )
        )]
      );
    }
  }]);
  return EditorClassName;
}(_react.Component);

EditorClassName.propTypes = {
  value: _propTypes2['default'].string,
  onChange: _propTypes2['default'].func,
  classNameArray: _propTypes2['default'].array,
  header: _propTypes2['default'].string,
  placeholder: _propTypes2['default'].string,
  locale: _propTypes2['default'].object
};
EditorClassName.defaultProps = {
  value: '',
  onChange: function onChange() {}
};
exports['default'] = EditorClassName;


EditorClassName.componentName = 'EditorClassName';
module.exports = exports['default'];